package com.quocnv.mediascanner;

import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileFilter;

public class SmbFileFilterUtil
{
	public static SmbFileFilter getMediaFilter()
	{
		SmbFileFilter mediaFileFilter = new SmbFileFilter()
		{
			private final String[] okFileExtensions = new String[]
			{ "mp3", "wav", "mp4", "wma" };

			@Override
			public boolean accept(SmbFile file)
			{
				for (String extension : okFileExtensions)
				{
					if (file.getName().toLowerCase().endsWith(extension))
					{
						return true;
					}
				}
				return false;
			}
		};

		return mediaFileFilter;
	}

	public static SmbFileFilter getVideoFilter()
	{
		SmbFileFilter videoFileFilter = new SmbFileFilter()
		{
			private final String[] okFileExtensions = new String[]
			{ "wmv", "mp4", "flv" };

			@Override
			public boolean accept(SmbFile file)
			{
				for (String extension : okFileExtensions)
				{
					if (file.getName().toLowerCase().endsWith(extension))
					{
						return true;
					}
				}
				return false;
			}
		};

		return videoFileFilter;
	}

	public static SmbFileFilter getAudioFilter()
	{
		SmbFileFilter audioFileFilter = new SmbFileFilter()
		{
			private final String[] okFileExtensions = new String[]
			{ "mp3", "wav", };

			@Override
			public boolean accept(SmbFile file)
			{
				for (String extension : okFileExtensions)
				{
					if (file.getName().toLowerCase().endsWith(extension))
					{
						return true;
					}
				}
				return false;
			}
		};

		return audioFileFilter;
	}
}
